<template>
	<view>
		<cmd-nav-bar back title="信息设置"></cmd-nav-bar>
		<cmd-page-body type="top">
			<cmd-transition name="fade-up">
				<view>
					<cmd-cel-item title="头像" slot-right arrow>
						<cmd-avatar src=""></cmd-avatar>
					</cmd-cel-item>
					<cmd-cel-item title="身份" :addon="infos.identity" arrow></cmd-cel-item>
					<cmd-cel-item title="昵称" :addon="infos.username" arrow></cmd-cel-item>
					<cmd-cel-item title="姓名" addon="xxx" arrow></cmd-cel-item>
					<cmd-cel-item title="联系方式" :addon="infos.mobile" arrow></cmd-cel-item>
					<cmd-cel-item title="证件号码" addon="450112xxxxxxxx2017" arrow></cmd-cel-item>
					<cmd-cel-item title="电子邮箱" :addon="infos.email" arrow></cmd-cel-item>
					<cmd-cel-item title="修改密码" @click="fnClick('modify')" arrow></cmd-cel-item>
				</view>
			</cmd-transition>
		</cmd-page-body>
	</view>
</template>

<script>
	import cmdNavBar from "@/components/cmd-nav-bar/cmd-nav-bar.vue"
	import cmdPageBody from "@/components/cmd-page-body/cmd-page-body.vue"
	import cmdTransition from "@/components/cmd-transition/cmd-transition.vue"
	import cmdCelItem from "@/components/cmd-cell-item/cmd-cell-item.vue"
	import cmdAvatar from "@/components/cmd-avatar/cmd-avatar.vue"
	import {
		publicing
	} from '../../../api/api.js'
	import {
		url
	} from '../../../api/request.js'

	export default {
		components: {
			cmdNavBar,
			cmdPageBody,
			cmdTransition,
			cmdCelItem,
			cmdAvatar
		},

		data() {
			return {
				infos: {
					email: "",
					mobile: "",
					identity: "",
					username: "",
				},
			};
		},
		created() {
			this.getUserinfo();
		},

		mounted() {},

		methods: {
			/**
			 * 点击触发
			 * @param {Object} type 跳转页面名或者类型方式
			 */
			fnClick(type) {
				if (type == 'modify') {
					uni.navigateTo({
						url: '/pages/owner/components/modify'
					})
				}
			},
			getUserinfo() {
				let Data = {
					id: sessionStorage.user_id
				}
				let Url = `${url}/user/info/`
				publicing(Url, Data)
					.then((res) => {
						this.infos = res.data
						if (res.data.stated == 0){
							this.infos.identity = '普通用户'
						}else{
							this.infos.identity = '志愿者'
						}
					})
					.catch((err) => {
						console.log(err)
					})
			}
		}
	}
</script>

<style>

</style>
